package javacafe.action.freeboard;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dto.bbspost.BbsPostDTO;
import javacafe.dto.member.LoginInfoDTO;
import javacafe.serviceimple.BbsPostServiceImple;


public class AddFreeBbsAction implements Action {
	
	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		ActionForward actfoward = new ActionForward();		
		BbsPostServiceImple service = BbsPostServiceImple.getInstance();		
		
		List<BbsPostDTO> list = null;
		BbsPostDTO dto = new BbsPostDTO();
		
		String m_no = request.getParameter("m_no");
		String title = request.getParameter("title");
		String writer = request.getParameter("writer");
		String content = request.getParameter("content");
				
		dto.setBbs_no(3);
		dto.setM_no(Integer.parseInt(m_no));		
		dto.setBp_title(title);
		dto.setBp_writer(writer);
		dto.setBp_content(content);
		dto.setBp_delflag(0);
		
		service.insertBbsPost(dto);
		
		list = service.getBbsPostList(dto);
				
		request.setAttribute("list",list);
		actfoward.setUrl("freebbsboard");
		return actfoward;
	}
}
